#include <bits/stdc++.h>
using namespace std;
const int N = 10000 + 10;
int l, m;
int a[N];
bool tree[N];
int main() {
  cin >> l >> m;
  memset(tree, 1, sizeof(tree));
  for (int i = 0; i < m; ++i) {
    int l, r;
    cin >> l >> r;
    for (int j = l; j <= r; ++j) {
      tree[j] = false;
    }
  }
  int cnt = 0;
  for (int i = 0; i <= l; ++i) {
    if (tree[i]) cnt++;
  }
  cout << cnt << endl;
}
